package at.ac.tuwien.lsds.util;

import java.util.ArrayList;
import java.util.List;

import at.ac.tuwien.lsds.model.Application;
import at.ac.tuwien.lsds.model.ScenarioEnum;

public class ApplicationOutputFile implements OutputFile {

	private List<Application> rowList = new ArrayList<Application>();
	private ScenarioEnum scenario;
	
	public ApplicationOutputFile(ScenarioEnum scenario) {
		this.scenario = scenario;
	}

	@Override
	public String getHeadline() {
		return "Timestamp"+Settings.getSeparator()+"Size"+Settings.getSeparator()+"RAM"+Settings.getSeparator()+"CPU"+Settings.getSeparator()+"Duration";
	}

	@Override
	public List<String> getContentRows() {
		List<String> stringRowList = new ArrayList<String>();
		
		for (Application app : rowList) {
			String out = "";
			out += app.getTimestamp().toString();
			out += Settings.getSeparator() + app.getHdd().toString();
			out += Settings.getSeparator() + app.getRam().toString();
			out += Settings.getSeparator() + app.getCpu().toString();
			out += Settings.getSeparator() + app.getDuration().toString();
			stringRowList.add(out);
		}
		return stringRowList;
	}
	
	public void addRow(Application app) {
		if(app!=null)
			rowList.add(app);
	}

	@Override
	public String getFilePath() {
		return Settings.getGeneratorDirectory() + "/inputData"+scenario.toString()+".csv";
	}

}
